﻿using System;
using System.Collections.Generic;
using EmbeddedSharp.Core;

namespace EmbeddedSharp.Scripting.Function.IO {

    public class FileDateNode : FuncNode {

        public FileDateNode()
            : base() {
            base.Value = "lastModifiedDate";
        }

        public override object Evaluate() {
            if (Parameters.Count < 1) {
                return "usage: lastModifiedDate(fileName)";
            }

            string fileName = (string) Parameters[0].Evaluate(); ;
            return System.IO.File.GetLastWriteTime(fileName);
        }
    }
}
